<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>机蜂博客管理后台</title>
    <base href="<%=request.getContextPath()%>/">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="static/layui/css/layui.css">
    <script src="static/jquery/jquery.js"></script>
    <script src="static/layui/layui.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black"><a href="admin/welcome" target="content"
                                                                style="color: white;text-decoration: none;">机蜂博客后台</a>
        </div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                <a href="javascript:;">
                    <img src="static/upload/${loginInfo.avatar}" class="layui-nav-img">
                    ${loginInfo.nickname}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:;" onclick="openInfo()">个人信息</a></dd>
                    <dd><a href="javascript:;" onclick="openPwd()">修改密码</a></dd>
                    <dd><a href="javascript:;" onclick="logout()">退出系统</a></dd>
                </dl>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item">
                    <a href="javascript:;">用户管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="admin/userinfo/list?role=1" target="content">管理员列表</a>
                        </dd>
                        <dd><a href="admin/userinfo/list?role=2" target="content">会员列表</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">博客管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="admin/category/list" target="content">分类列表</a>
                        </dd>
                        <dd><a href="admin/article/list" target="content">文章列表</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="admin/banner/list" target="content">广告管理</a>
                </li>
                <li class="layui-nav-item">
                    <a href="admin/website/info" target="content">系统管理</a>
                </li>
                <li class="layui-nav-item">
                    <a href="admin/welcome" target="content" onclick="clearCache()">清理缓存</a>
                </li>
            </ul>
        </div>
    </div>
    <div class=" layui-body" style="padding: 10px">
        <!-- 内容主体区域 -->
        <iframe name="content" style="height: 100%;width: 100%" src="admin/welcome" frameborder="no"
                border="0"
                marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>
    </div>
    <div class="layui-footer">
        <p style="text-align: center">开发人员：刘德虎</p>
    </div>
</div>
<script>
    function logout() {
        layer.confirm('确定退出系统吗？', {icon: 3, title: "询问"}, function (index) {
            location.replace("admin/logout")
            layer.close(index)
        })
    }

    function openInfo() {
        layer.open({
            type: 2,
            content: "admin/userinfo/edit?userinfoId=${loginInfo.userinfoId}&type=info",
            area: ["600px", "600px"]
        })
    }

    function openPwd() {
        layer.open({
            type: 2,
            content: "admin/userinfo/password",
            area: ["400px", "400px"]
        })
    }

    function clearCache() {
        layer.confirm('确定清空缓存信息吗？', {icon: 3, title: '询问'}, function () {
            $.ajax({
                url: "clear/cache",
                method: "get",
                dataType: "json",
                success(res) {
                    if (res.code === 200) {
                        layer.msg('清理成功！', {icon: 1});
                    } else {
                        layer.msg(res.msg);
                    }
                },
                error(e) {
                    console.log(e)
                    layer.alert('服务器睡着了')
                }
            });
        })
    }
</script>
</body>
</html>
